from app.outdoor.models import ActivityType
from common.dictInfo import model_to_dict
from common.authCheck.userAuth import check_login
from common.paginator import paginator
from django.http import JsonResponse
from rest_framework.views import APIView


class ActivityTypeListInfoView(APIView):

    @check_login
    def get(self, request):
        """
        获取活动类型列表
        :param request:
        :return:
        """
        allType = ActivityType.objects.all()
        # pageAllType = paginator(allType, request.GET.get('page')) # 暂时不需要分页
        typeDict = [model_to_dict(types, fields='name') for types in allType]
        return JsonResponse({
            'status': True,
            'type_list': typeDict
        })
